//本地缓存键值保存
import 'package:app/src/http/url.dart';
import 'package:app/src/manager/user_manager.dart';

class AppKey {
  /**
   * 基本键
   * @param isUserId 是否包含用户id,默认包含。
   */
  static String getBaseKey({bool isUserId = true}) {
    if (isUserId) {
      var id = UserManager.getUserInfo()?.PersonId;
      if (id != null) {
        return Url.baseurl() + id; //url+登录用户id
      }
    }
    return Url.baseurl();
  }

  //服务器地址
  static String getAdressKey() {
    return "mAdress";
  }

  //历史服务器地址
  static String getAdressHistoryKey() {
    return "mAdressHistory";
  }

  //密钥(完整的)
  static String getAppSecretKey() {
    return "API_SIGN_APPSECRET";
  }

  //密钥（用户手输的）
  static String getAppSecretCustomKey() {
    return "API_SIGN_CUSTOMSECRET";
  }

  //工厂键值
  static String getFactoryKey() {
    return getBaseKey(isUserId: false) + "API_FACTORY";
  }

  ///用户
  static String getUserInfoKey() {
    return getBaseKey(isUserId: false) + "userInfo";
  }

  ///用户工号（记录用户工号，方便登录）
  static String getUserInfoPersonCodeKey() {
    return getBaseKey(isUserId: false) + "userInfo_personCode";
  }

  ///班组
  static String getGroupBcInfoKey() {
    return getBaseKey(isUserId: true) + "GroupBcInfo";
  }

  ///班次
  static String getAttendancesKey() {
    return getBaseKey(isUserId: true) + "attendances";
  }

  ///token
  static String getTokenKey() {
    return "mToken";
  }

  ///二维码扫码标识
  static String getTokenBwg() {
    return "token_bwg";
  }

  ///历史搜索
  static String getKeyWithHistoryWithSearch() {
    return "history_search";
  }

  ///常用功能
  static String getKeyWithUsed() {
    return getBaseKey(isUserId: true) + "used_items";
  }

  //手机号验证
  static String getKeyWithMobile() {
    return getBaseKey(isUserId: true) +
        "Mobile${UserManager.getUserInfo()?.MobileNum}";
  }

  //待审核通知存储时间
  static String getKeyWithInsertDatetime() {
    return getBaseKey(isUserId: true) +
        "YwxItemNotice_InsertDatetime";
  }

  //工单最新时间
  static String getKeyWithEquipmentInfoDatetime() {
    return getBaseKey(isUserId: true) +
        "YwxItemNotice_EquipmentInfoDatetime";
  }

}
